package com.reebake.ideal.captcha.handler;

import cn.hutool.core.bean.BeanUtil;
import com.anji.captcha.service.CaptchaService;
import com.reebake.ideal.captcha.core.SmartCaptchaService;
import com.reebake.ideal.captcha.entity.CaptchaRequestEntity;
import com.reebake.ideal.captcha.entity.CaptchaResponseEntity;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;

@Setter
public class DefaultSmartCaptchaService implements SmartCaptchaService {
    @Autowired
    private CaptchaService captchaService;

    @Override
    public CaptchaResponseEntity get(CaptchaRequestEntity captchaRequestEntity) {
        return BeanUtil.copyProperties(captchaService.get(captchaRequestEntity), CaptchaResponseEntity.class);
    }

    @Override
    public CaptchaResponseEntity check(CaptchaRequestEntity captchaRequestEntity) {
        return BeanUtil.copyProperties(captchaService.check(captchaRequestEntity), CaptchaResponseEntity.class);
    }

    @Override
    public CaptchaResponseEntity verify(CaptchaRequestEntity captchaRequestEntity) {
        return BeanUtil.copyProperties(captchaService.verification(captchaRequestEntity), CaptchaResponseEntity.class);
    }
}
